<%@ page contentType="text/html; charset=utf-8" language="java" %>
<%@ page isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Pragma" content="no-cache">
<link href="../style.css" rel="stylesheet" type="text/css">
<link href="<c:url value='/admin/assets/style/jqueryform.css'/>" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="<c:url value='/admin/assets/js/util.js'/>"></script>
<script type="text/javascript" src="<c:url value='/admin/assets/js/md5.js'/>"></script>
<script type="text/javascript" src="<c:url value='/admin/assets/js/jquery/jquery.js'/>"></script>
<script type="text/javascript" src="<c:url value='/admin/assets/js/jquery/jquery-validate/lib/jquery.metadata.js'/>"></script>
<script type="text/javascript" src="<c:url value='/admin/assets/js/jquery/jquery-validate/jquery.validate.js'/>"></script>
<script type="text/javascript" language="javascript">
// <![CDATA[
$(document).ready(function() {
	var validator = $("#userForm").validate({
		rules: {
			password: 		        {password: true},
			password_confirm: 		{equalTo: "#password" },
			mobile: 				{required: true}
		},
		messages: {
			password: {
				password:"新密码 最多是 50 个字符"
			},
			password_confirm: {
				equalTo:"两次输入的密码必须相同"
			},
			mobile: {
				required:"请输入手机号码. "
			}
		}   
	});
	
	
<c:if test="${not empty requestScope.message}">
$("#infoSpan").html("<img src='<c:url value='/admin/assets/images/warning.gif'/>'><font color='#C00000'><c:out value='${requestScope.message}' escapeXml='false'/></font>");
</c:if>

});

// ]]>
</script>
<script language="javascript">
function check()
{
	
	var userName = document.getElementById("userName");
	var password = document.getElementById("password");
	var password1 = document.getElementById("password1");
	var telephone = document.getElementById("telephone");
	var email = document.getElementById("email");
	
	if(userName.value.trim()=="")
	{
		OS.showWarming("errorTd","请输入帐户!");
		userName.focus();
		return false;
	}
	else
	{
		OS.hideWarming("errorTd");
	}
	/**
	if(password.value=="")
	{
		OS.showWarming("errorTd","请输入密码！");
		password.focus();
		return false;
	}
	else
	{
		OS.hideWarming("errorTd");
	}
	
	if(password.value.length<6)
	{
		OS.showWarming("errorTd","密码最小长度为6位！");
		password.focus();
		return false;
	}
	else
	{
		OS.hideWarming("errorTd");
	}
	
	if(password.value!=password1.value)
	{
		OS.showWarming("errorTd","两次密码不一致！");
		password.focus();
		return false;
	}
	else
	{
		OS.hideWarming("errorTd");
	}
	***/
	if(email.value.trim()!="")
	{
		if(!IsEmail(email.value.trim()))
		{
			OS.showWarming("errorTd","请检查邮件格式是否正确！");
			email.focus();
			return false;
		}
		else
		{
			OS.hideWarming("errorTd");
		}
	}
	
	dojo.io.bind({
			url: "user.do?method=editOk",
			formNode:dojo.byId("userForm"),
			mimetype:"text/html",
			method:"POST",
			encoding:"UTF-8",
			timeout:10000, 
			preventCache:true,
			load: function(type, data, evt){
				if(data=="existCode")
				{
					OS.showWarming("errorTd","添加失败，相同卡号已经存在！");
				}
				else
				{
					window.location = "user.do?method=list";
				}
			},
			error: function(type, error){
				
			},
			timeout: function(type, data, evt){
				
			}
		});
		return false;
}

window.onload = function()
{
	<c:if test="${requestScope.user!=null}">
		var sex = "${requestScope.user.sex}";
		if(sex=="男")
		{
			document.getElementById("sexOne").checked = true;
			document.getElementById("sexTwo").checked = false;
		}
		else
		{
			document.getElementById("sexOne").checked = false;
			document.getElementById("sexTwo").checked = true;
		}
	</c:if>
}
</script>
</head>
<body class="main">
<form method="post" name="userForm" id="userForm" action="<c:url value='/admin/user/user-edit.ac'/>">
<input type="hidden" id="id" name="id" value="${requestScope.user.id}"/>
<table class="container" cellpadding="0" cellspacing="0">
<tr><td>
<table class="dialog" align="center" cellpadding="0" cellspacing="0" width="700">
<tr><td>
<table class="header" cellpadding="0" cellspacing="0">
<tr>
<td>会员名信息编辑</td>
</tr>
</table>
</td></tr>
<tr>
  <td class="body">
<table class="body" cellpadding="0" cellspacing="0">
<tr>
  <td colspan="2" align="center" id="errorTd">&nbsp;<span id="infoSpan" class="infoSpan">&nbsp;</span></td>
</tr>
<tr>
  <td width="25%" align="right"><strong>会员名：</strong></td>
  <td width="75%"><input type="text" name="userName" id="userName" size="31" maxlength="31" value="${requestScope.user.userName}" readonly>
</tr>
<tr>
<td align="right"><strong>密码：</strong></td>
<td><input type="password" name="password" id="password" size="31" maxlength="31" >
</tr>
<tr>
<td align="right"><strong>确认密码：</strong></td>
<td><input type="password" name="password_confirm" id="password_confirm" size="31" maxlength="31" >
</tr>
<tr>
  <td align="right"><strong>姓名：</strong></td>
  <td><input type="text" name="realName" id="realName" size="31" maxlength="31" value="${requestScope.user.realName}">  
</tr>
<tr>
  <td align="right"><strong>性别：</strong></td>
  <td><label>
    <input name="sex" type="radio" id="sexOne" value="男" checked> 男
  </label>
    
    <label>
      <input type="radio" name="sex" id="sexTwo" value="女"> 女 
    </label> 
   
</tr>
<tr>
  <td align="right"><strong>地址：</strong></td>
  <td><input type="text" name="address" id="address" size="50" maxlength="31" value="${requestScope.user.address}">
</tr>  
<tr>
  <td align="right"><strong>邮编：</strong></td>
  <td><input type="text" name="zip" id="zip" size="31" maxlength="31" value="${requestScope.user.zip}" onKeyUp="value=value.replace(/[^0-9]/g,'')">  
</tr>
<tr>
<td align="right"><strong>手机号码：</strong></td>
<td><input type="text" name="mobile" id="mobile" size="31" maxlength="31" value="${requestScope.user.mobile}" onKeyUp="value=value.replace(/[^0-9]/g,'')">
</tr>
<tr>
  <td align="right"><strong>电子邮件：</strong></td>
  <td><input type="text" name="email" id="email" size="31" maxlength="31" value="${requestScope.user.email}">  
</tr>
<tr>
  <td align="right"><strong>所在国家：</strong></td>
  <td><input type="text" name="country" id="country" size="31" maxlength="31" value="${requestScope.user.country}" />  
</tr>
<tr>
  <td align="right"><strong>所在城市：</strong></td>
  <td><input type="text" name="city" id="city" size="31" maxlength="31" value="${requestScope.user.city}" />  
</tr>
<tr>
  <td align="right"><strong>所在县区：</strong></td>
  <td><input type="text" name="county" id="county" size="31" maxlength="31" value="${requestScope.user.county}" />  
</tr>
<tr>
  <td align="right"><strong>备注：</strong></td>
  <td><textarea id="options" name="options" style="width:99%;height:100px">${requestScope.user.options}</textarea>
  </tr>

</table>
</td></tr>
<tr><td>
<table class="footer" cellpadding="0" cellspacing="0">
<tr><td>
<input class="button" type="submit" value="确定">
&nbsp;&nbsp;<input class="button" type="button" value="返回" onClick="document.location='javascript:history.go(-1)'">
</td></tr>
</table>
</td></tr>
</table>
</td></tr>
</table>
</form>

</body>
</html>
